<template>
	<u-navbar :title="title" :bgColor="bgColor" :titleStyle="{'color':'#FFFFFF','font-size':'18px','font-weight':'500'}"
		:fixed="true">
		<!-- #ifdef APP-PLUS || APP-PLUS-NVUE -->
		<view class="u-left" slot="left" @click.stop="leftBack">
			<image class="back" src="https://oss.jxhecong.com/v2/image/back_white@2x.png"></image>
		</view>
		<!-- #endif -->
		<!-- #ifdef MP-WEIXIN -->
		<view class="u-left" slot="left" @click.stop="back">
			<image class="back" src="https://oss.jxhecong.com/v2/image/back_white@2x.png"></image>
		</view>
		<!-- #endif -->
		<!-- #ifdef MP-ALIPAY -->
		<view class="u-left" slot="left" @click.stop="back">
			<!-- <image class="back" src="https://oss.jxhecong.com/v2/image/back_white@2x.png"></image> -->
		</view>
		<!-- #endif -->
		<view class="u-nav-right" slot="right">
			<slot name="right">
			</slot>
		</view>
	</u-navbar>
</template>

<script>
	export default{
		props:{
			title:{
				type:String,
				default:''
			},
			bgColor:{
				type:String,
				default:'#6ABF6C'
			},
			leftBack:{
				type:Function
			}
		},
		methods:{
			back(){
				if(this.leftBack) {
					this.leftBack()
				} else {
					let pages=getCurrentPages()
					if(pages.length==1){
						uni.reLaunch({
							url:'/pages/index/index'
						})
					}
					else{
						uni.navigateBack({
							delta:1
						})
					}
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.u-left {
		width: 80rpx;
		height: 80rpx;
		.back {
			margin-top: 22rpx;
			width: 36rpx;
			height: 36rpx;
		}
	}
</style>
